<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Axios简化</title>
	</head>
	<body>
		<script src="../js/axios.js"></script>
		<script>
			
			axios.get("http://localhost:8080/getUserById",{
				params: {
						id: 1,
						
				}
			}).then(result=>{
				console.log(result.data)
			})
			
			
			//函数定义
			async function getUser(){
				const result = await axios.get("http://localhost:8080/getUserById",{
					params: {id: 1}
				})
				console.log("Axios的简化")
				console.log(result.data)
			}
			
			async function getUser2(){
				const {data: result} = await axios.get("http://localhost:8080/getUserById",{
					params: {id: 2}
				})
				console.log("解构赋值")
				console.log(result)
			}
			
			//函数调用
			getUser()
			getUser2()
			
			
			
			
			
		</script>
	</body>
</html>
